﻿#include "bullet.h"
#include "config.h"

Bullet::Bullet()
{
    bullet.load(":/res/bullet1.png");
    postion_x = GAME_WIDTH*0.5 -  bullet.width()*0.5;
    postion_y = GAME_HEIGHT;
    is_free = true;
    speed = 5;
    bulletRect.setWidth(bullet.width());
    bulletRect.setHeight(bullet.height());
    bulletRect.moveTo(postion_x,postion_y);
}

void Bullet::updatePostion()
{
    if(is_free){
        return;
    }

    postion_y -=speed;
    bulletRect.moveTo(postion_x,postion_y);

    if(postion_y <= - bulletRect.height()){
        is_free = true;
    }

}

bool Bullet::getIsFree() const
{
    return is_free;
}

void Bullet::setIsFree(bool value)
{
    is_free = value;
}

int Bullet::getPostionX() const
{
    return postion_x;
}

void Bullet::setPostionX(int value)
{
    postion_x = value;
}

int Bullet::getPostionY() const
{
    return postion_y;
}

void Bullet::setPostionY(int value)
{
    postion_y = value;
}

QPixmap Bullet::getBullet() const
{
    return bullet;
}

void Bullet::setBullet(const QPixmap &value)
{
    bullet = value;
}

QRect Bullet::getBulletRect() const
{
    return bulletRect;
}
